package day03_ThreadPool.homework;

// SingleChoice 类
class SingleChoice extends Question {
    private final String[] options;
    private final char correctAnswer;

    public SingleChoice(String questionText, String[] options, char correctAnswer) {
        super(questionText);
        this.options = options;
        this.correctAnswer = correctAnswer;
    }

    @Override
    public boolean checkAnswer(Object answer) {
        if (answer instanceof Character) {
            return Character.toUpperCase((Character)answer) == Character.toUpperCase(correctAnswer);
        } else if (answer instanceof String) {
            String strAnswer = ((String)answer).toUpperCase();
            return strAnswer.length() == 1 && strAnswer.charAt(0) == Character.toUpperCase(correctAnswer);
        }
        return false;
    }

    public String[] getOptions() {
        return options;
    }

    public char getCorrectAnswer() {
        return correctAnswer;
    }
}

